package com.bootssm.controller;

import com.bootssm.entity.Sleep;
import com.bootssm.entity.Sports;
import com.bootssm.service.HealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("health")
@RestController
public class HealthController {
    @Autowired
private HealthService healthService;
    //作息模块
    //1.查询一个前3条
//    2.增加
//    3.删除
//    4.评分
    @GetMapping("findSleep")
    public List<Sleep> findSleep(String userId){
        List<Sleep> sleepList = healthService.findSleep(userId);
        System.out.println(sleepList);
        return sleepList;
    }
    @PutMapping("addSleep")
    public void  addSleep(Integer bedtime,String userId){
        Sleep sleep = new Sleep();
        sleep.setUserId(userId);
        sleep.setBedtime(bedtime);
        healthService.addSleep(sleep);
    }
@DeleteMapping("deleteSleep")
    public  void  deleteSleep(String id){

    System.out.println(id);
        healthService.deleteSleep(id);
    }
    @GetMapping("selectSleepScore")
    public Integer selectSleepScore(String userId){
       return healthService.selectSleepScore(userId);
    }
    //疾病模块
//    1.查询前三条
    // 2.增加
//    3.删除
    //  4.评分

    //饮食模块
    //1.查询一个前3条
    // 2.增加
   //  3.删除
    // 4.评分

    //运动模块
    //1.查询一个前3条
    //  2.增加
    //  3.删除
    //  4.评分
    @GetMapping("findSports")
    public List<Sports> findSports(String userId){
        System.out.println(healthService.findSports(userId));
        return healthService.findSports(userId);
    }
    //  2.增加
    @PutMapping("addSports")
    public void addSports(String time,String type,String userId){

        System.out.println(time+type);
        healthService.addSports(type,time,userId);
    }
    //  3.删除
    @DeleteMapping("deleteSports")
    public void deleteSport(String id){
        healthService.deleteSports(id);
    }
    //  4.评分
    @GetMapping("findSportsSocore")
    public Integer findSportsScore(String userId){
      return   healthService.findSportsScore(userId);
    }







}
